'use strict';

const Controller = require('egg').Controller;

class SendMailController extends Controller {
  async create() {
    const { ctx } = this
    const { mailbox, information, intro } = ctx.request.body
    try {
      const res = await ctx.service.sendMail.sendMail(mailbox, information, intro)
      if (res && res?.response) {
        ctx.body = {
          code: 200,
          msg: "发送成功"
        }
      }
    } catch (err) {
      ctx.body = {
        code: 400,
        msg: "发送失败"
      }
    }
  }
}

module.exports = SendMailController;
